package es.juanc.logging.log4j;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;

public class ConfigLg4jTest {

//	static {
//		
//	}
	private static Logger log;
	
	private static void configureLog() {
				
//		RollingFileAppender logAppFile = new RollingFileAppender( new PatternLayout(Pattern), "urlogfileName"+arg[0], true ); 
//		logAppFile.setThreshold( Level.ALL );
//		logAppFile.setMaxBackupIndex( 20 );
//		logAppFile.setMaxFileSize( "5000KB" ); 
		
		//BasicConfigurator.configure();
		//BasicConfigurator.configure( appdender );
		//PropertyConfigurator.configure( "log4j.properties" );
		
		Logger logger = LogManager.getLogger( "es.juanc.log4j" );
		FileAppender appdender = (FileAppender) logger.getAppender( "FILE" );
		
		//FileAppender appdender = (FileAppender) log.getParent().getAppender( "FILE" );
		appdender.setFile( appdender.getFile().replace( "(time)" , new SimpleDateFormat( "hh-mm-ss_ddMMyyyy" ).format( new Date() ) ) );
		appdender.activateOptions();
		
		log = Logger.getLogger( ConfigLg4jTest.class );		                    
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		configureLog();
		
		log.info( "la traza" );

	}

}
